@extends('admin.layout')

@section('content')
    <script>
        function del()
        {
            if(confirm("确定要删除吗？"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    </script>
    <div class="content-wrapper" >
        <!-- Content Header (Page header) -->
        <section>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a href="#">管理员</a></li>
                <li class="active">用户列表</li>
            </ol>
            <div class="input-group margin">
                <form action="{{ url('admin/manage') }}" method="post" >
                    {{ csrf_field() }}
                    <select style="width: 150px"  name="searchtype" class="form-control">
                        @foreach($manages['searchtype'] as $value)
                            <option value="{{ $value['id'] }}">{{ $value['searchtype'] }}</option>
                        @endforeach
                    </select>
                    <input style="width: 200px"  name="param" type="text" class="form-control">
                    <input  type="submit" class="btn btn-info btn-flat" value="Go!">
                </form>
            </div>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-lg-12">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">内容</h3>
                        </div>
                        <span id="msg" style="display: none">
                            @if (count($errors) > 0)
                                @foreach ($errors->all() as $error)
                                    <div style="width: 100%;">
                                        <span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
                                    </div>
                                @endforeach
                            @else
                                <div style="width: 100%;">
                                    <span style="color: green;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ Session::get('msg') }}</span>
                                </div>
                            @endif
                        </span>
                        <script type="text/javascript">
                            var _msg = $('#msg div span').text();
                            console.log(_msg);
                            if(_msg != ''){
                                layer.msg(_msg);
                            }
                        </script>
                        <!-- /.box-header -->
                        <div class="box-body" style="overflow: auto;">
                            <table class="table table-bordered"  style=" text-align: center;">
                               <tr>
                                    @foreach($manages['searchtype'] as $value)
                                        <th style="text-align:center;min-width: 120px;">{{ $value['searchtype'] }}</th>
                                    @endforeach
                                    <th style="text-align: center;min-width: 220px;">操作</th>
                                </tr>
                                @foreach($manages['data'] as $manage)
                                    <tr>
                                        <td>{{ $manage['id'] }}</td>
                                        <td>{{ $manage['create_time']}}</td>
                                        <td>{{ $manage['update_time']}}</td>
                                        <td>{{ $manage['username']}}</td>
                                        <td>{{ $manage['rolename']}}</td>
                                        <td>{{ $manage['email']}}</td>
                                        <td>{{ $manage['phone']}}</td>
                                        <td>{{ $manage['ip']}}</td>
                                        <td>{{ $manage['login_time']}}</td>
                                        <td>{{ $manage['login_number']}}</td>
                                        <td>
                                            @if($manage['status'] == 1)<a class="btn btn-success btn-xs">已启用<a>
                                            @else    <a class="btn btn-danger btn-xs">已禁用<a>
                                            @endif
                                        </td>
                                        <td  style="text-align:center;">
                                            <a class="btn btn-success btn-xs"  href="{{ url('admin/setStatus/'.$manage['id'].'/1') }}">启用<a>
                                            <a class="btn btn-warning btn-xs"  href="{{ url('admin/setStatus/'.$manage['id'].'/0') }}">禁用<a>
                                            <a class="btn btn-warning btn-xs"  href="{{ url('admin/getManage/'.$manage['id']) }}">修改<a>
                                            <a class="btn btn-danger btn-xs" href="{{ url('admin/delManage/'.$manage['id']) }}" onclick='return del()'>删除<a>
                                        </td>
                                    </tr>
                                @endforeach
                            </table>
                        </div>
                        <div calss="pages" style="text-align: center;">
                            {{ $man->links() }}
                        </div>

                        <!-- /.box -->
                    </div>

                    <!-- /.row -->

        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
@stop
